<template>
  <div class="head-title">
    <van-nav-bar left-text="返回" :title = title  left-arrow fixed @click-left="onClickLeft" />
    <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
      <!-- <router-link :to="{path:'/overWorkNote', query: {Id:item.id}}"> -->
         <van-cell v-for="(item,index) in list" :key="index"  @click="goNOte(index)">
            {{ item.id  + item.name}}
         </van-cell>
      <!-- </router-link> -->
    </van-list>
  </div>
</template>

<script>

export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      title:'',
    };
  },
  methods: {
    
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        // for (let i = 0; i < 10; i++) {
        //   this.list.push(this.list.length + 1);
        // }
        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.list.length >= 40) {
          this.finished = true;
        }
      }, 1000);
    },
    GetFiles() {
      this.$axios({
        method: "get",
        url: "/api/User/GetFileCategories",
        params: {
          categoryid: 1
        }
      })
        .then(res => {
          if (res.data.code === 0) {
            // console.log(res.data.data);
            this.list = res.data.data;
          }
          if (res.data.Code == 1) {
            this.$toast({
              duration: 800,
              message: res.data.Message
            });
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    goNOte(index){
       this.$router.push({
            path: "/AddVideoNote",
            query: {
            ID:this.list[index].id,
            name:this.list[index].name
            //   categoryTitle:this.title
            }
      });
    },
    //返回
    onClickLeft() {
      this.$router.go(-1);
    },
  },
  //页面初始化钩子函数 created
  created() {
    this.GetFiles();
    this.title = this.$route.query.title;
    // this.isActive = 0;
    this.$emit("header", false);
    this.$emit("footer", false);
  },
  //页面初始化钩子函数 mounted
  mounted() {}
};
</script>
<style lang="less" scoped>

</style>

